package tree;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

/**
 * Servlet implementation class TreeServlet
 */

public class TreeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stu
		System.out.println("1234567");
		String json="";
		TreeService xzqService=new TreeService();
		try{
			json = JSON.toJSONString(xzqService.tree());
			System.out.println(json);
		}catch(Exception e){
			
		}
		response.setContentType("text/plain;charset=utf-8");  
		response.setCharacterEncoding("utf-8"); 
		PrintWriter out = null;  
		try{
			out=response.getWriter();
			out.write(json);
			out.flush();
		}catch(Exception e){
			
		}
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
